#include <iostream>

using namespace std;
struct Listnode {
    Listnode() {
        num = 0;
    }
    Listnode(int data) {
        num = data;
        next = NULL;
    }
    void insert(int x) {
        Listnode *pf = new Listnode(x);
        if (head->next == NULL)
        {
            head->next = pf;
            return;
        }
        Listnode *p = head->next;
        x -= 2;
        while (x--)
        {
            p = p->next;
        }
        if (p->next == NULL)
        {
            p->next = pf;
            return;
        }
        Listnode *p1 = p->next;
        p->next = pf;
        pf->next = p1;
        return;
    }
    void List_delete(int x)
    {
        if (head->next == NULL)
        {
            cout << "no node" << endl;
            return;
        }
        Listnode *p = head->next;
        Listnode *pf = head;
        while (p != nullptr)
        {
            if (p->num == x)
            {
                pf->next = p->next;
            }
            p = p->next;
            pf = pf->next;
        }
        return;
    }
    int List_find(int x)
    {
        if (head->next == NULL)
        {
            cout << "no node" << endl;
            return 0;
        }
        Listnode *p = head->next;
        while (p != NULL)
        {
            if (p->num == x)
            {
                return p->num;
            }
            p = p->next;
        }
        cout << "no data" << endl;
        return 0;
    }
    void List_print()
    {
        if (head->next == NULL)
        {
            cout << "no node" << endl;
            return;
        }
        Listnode *p = head->next;
        cout << "==" << endl;
        while (p != NULL)
        {
            cout << p->num << endl;
            p = p->next;
        }
        cout << "==" << endl;
    }
    int num;
    Listnode *head;
    Listnode *next;
};

int main()
{
    cout << "请输入总数" << endl;
    cout << "n" << endl;
    int n = 0;
    cin >> n;
    Listnode *head1 = new Listnode();
    head1->head = head1;
    Listnode *p = head1;
    for (int i = 0; i < n; i++)
    {
        int m = 0;
        cout << "请输入编号" << endl;
        cout << "" << endl;
        cin >> m;
        Listnode *p1 = new Listnode(m);
        p->next = p1;
        p = p1;
    }
    head1->List_print();
    head1->insert(3);
    head1->List_print();
    head1->List_delete(2);
    head1->List_print();
    cout << head1->List_find(2) << endl;
    cout << head1->List_find(3) << endl;
    return 0;
}
